package Observer;
// 环境信息采集模块（被观察者）

import Factory.AgriculturalMachine;

import java.util.ArrayList;
import java.util.List;

public class EnvironmentDataCollector {
    private List<AgriculturalMachine> observers = new ArrayList<>();
    private EnvironmentData currentData;

    public void addObserver(AgriculturalMachine observer) {
        observers.add(observer);
    }

    public void removeObserver(AgriculturalMachine observer) {
        observers.remove(observer);
    }

    public void notifyObservers() {
        for (AgriculturalMachine observer : observers) {
            observer.planPath(currentData);
        }
    }

    public void updateData(EnvironmentData data) {
        this.currentData = data;
        notifyObservers();
    }
}